export default {
    addCart(context, goods) {
        return new Promise((resolve, reject) => {
            let product = context.state.cartList.find(item => item.iid === goods.iid)
            if (product) {
                // 购物车中有此商品，数量加一
                context.commit('addCount', product)
                resolve('当前商品数量+1')
            } else {
                // 购物车无此商品。添加新商品
                goods.count = 1
                goods.checked = true
                context.commit('addGood', goods)
                resolve('增加新商品到购物车')
            }
        })

    }
}